/*
 * @LastEditors: tangdy tdy853839625@qq.com
 * @FilePath: /HumanGenerateVideo/src/store/modules/auth/shared.ts
 */
import { localStg } from '@/utils/storage';

/** Get token */
export function getToken() {
  return localStg.get('humanToken') || '';
}

/** Get user info */
export function getUserInfo() {
  const emptyInfo: any = {
    id: '',
    userid: '',
    phone: '',
    createTime: '',
    userId: '',
    userName: '',
    roles: [],
    buttons: []
  };
  const userInfo = Object.assign(emptyInfo, localStg.get('userInfo') ?? {});

  return userInfo;
}

/** Clear auth storage */
export function clearAuthStorage() {
  localStg.remove('humanToken');
  localStg.remove('refreshToken');
  localStg.remove('userInfo');
}
